unit HighscoreEntry;

interface

uses
  System.IO, System.Collections;

type
  THighscoreEntry = class
  private
    { Private Declarations }
    _name : String;
    _score : System.Decimal;
  public
    property Name : String read _name write _name;
    property Score : System.Decimal read _score write _score;

    constructor Create(n : String; s : System.Decimal);
    procedure Write(writer : BinaryWriter);

    class function Read(reader : BinaryReader) : THighscoreEntry;
  end;

implementation

constructor THighscoreEntry.Create(n : String; s : System.Decimal);
begin
  inherited Create;

  self.Name := n;
  self.Score := s;
end;

procedure THighscoreEntry.Write(writer: BinaryWriter);
begin
  writer.Write(self.Score);
  writer.Write(self.Name);
end;

class function THighscoreEntry.Read(reader: BinaryReader) : THighscoreEntry;
var
  s : System.Decimal;
  n : String;

begin
  s := reader.ReadDecimal();
  n := reader.ReadString();

  result := THighscoreEntry.Create(n, s);
end;

end.
